/*!
\copyright  Copyright (c) 2023 - 2024 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\version
\file       lateny_config.c
\brief      Definitions of latency.

        For TWS standard, latencies are measured from arrival of audio in the
        audio subsystem to the synchronised rendering by TWS master and TWS
        slave.
*/

#include "latency_config.h"

#define TWS_STANDARD_KICK_PERIOD_MS     10

typedef struct latency_config_t {
    uint32_t latency_ms;
    uint32_t kick_period_ms;
} latency_config_t;

static latency_config_t latency_config = {
    .latency_ms = TWS_STANDARD_LATENCY_MS,
    .kick_period_ms = TWS_STANDARD_KICK_PERIOD_MS,
};

uint32_t LatencyConfig_GetTwsLatency(void)
{
    return latency_config.latency_ms;
}

void LatencyConfig_SetTwsLatency(uint32_t latency_ms)
{
    latency_config.latency_ms = latency_ms;
}

uint32_t LatencyConfig_GetKickPeriod(void)
{
    return latency_config.kick_period_ms;
}

void LatencyConfig_SetKickPeriod(uint32_t kick_period_ms)
{
    latency_config.kick_period_ms = kick_period_ms;
}

void LatencyConfig_RestoreDefaults(void)
{
    LatencyConfig_SetTwsLatency(TWS_STANDARD_LATENCY_MS);
    LatencyConfig_SetKickPeriod(TWS_STANDARD_KICK_PERIOD_MS);
}
